package org.jeecg.modules.oa.mapper;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.oa.entity.OaReportPlan;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

/**
 * @Description: 周报子表
 * @Author: jeecg-boot
 * @Date: 2019-09-17
 * @Version: V1.0
 */
@Repository
public interface OaReportPlanMapper extends BaseMapper<OaReportPlan> {

    List<OaReportPlan> getReportPlanById(String id);

    @Select("select id from oa_report_plan where parent_id = #{parentId} and plan_status=#{planStatus} and del_flag = '0' order by sort_no ")
    List<String> getByParentIdAndPlanStatus(@Param("parentId") String parentId,@Param("planStatus") String planStatus);

    @Select("select * from oa_report_plan where parent_id = #{parentId} and plan_status='0' and del_flag = '0' order by sort_no ")
    List<OaReportPlan> getByParentIdAndPlanStatus0(@Param("parentId") String parentId);

    @Select("select * from oa_report_plan where parent_id = #{parentId} and plan_status='1' and del_flag = '0' order by sort_no ")
    List<OaReportPlan> getByParentIdAndPlanStatus1(@Param("parentId") String parentId);

    @Select("select * from oa_report_plan where create_by = #{createId} and plan_status='1' and del_flag = '0' and work_date_from <= #{lastWeekDate} and work_date_to >= #{lastWeekDate} order by sort_no ")
    List<OaReportPlan> getThisWeekPlan(@Param("createId")String createId, @Param("lastWeekDate")Date lastWeekDate);

    @Update("update oa_report_plan set del_flag = '1' where id = #{id} ")
    int logicDeleteById(@Param("id")String id);
}
